#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    void swap(int& a, int& b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }
    void moveZeroes(vector<int>& nums) {
        int dest = -1, cur = 0;
        while (cur < nums.size())
        {
            if (nums[cur] == 0)
            {
                ++cur;
            }
            else if (nums[cur] != 0)
            {
                swap(nums[++dest], nums[cur]);
                ++cur;
            }
        }
    }
};